#ifndef CAPTUREPAGE_H
#define CAPTUREPAGE_H

#include <QWidget>
#include <QPushButton>
#include <QScrollArea>
#include <QVBoxLayout>
#include "capturepacket.h"

namespace Ui {
class CapturePage;
}

class CapturePage : public QWidget
{
    Q_OBJECT

public:
    explicit CapturePage(const QString &interfaceName,QWidget *parent = nullptr);
    void stopCapture();
    void startCapture();
    ~CapturePage();
signals:
    //goback to parent
    void requestBack();

private:
    Ui::CapturePage *ui;
    QString interface;
    CapturePacket *capturePacket;
    void setButtonQSS(QPushButton* btn);
    void backToPrevPage();

    //mutex safety
    bool isCapturing = false;
    std::atomic<bool> stopRequested{false};

    //scroll area
    QVBoxLayout *scrollLayout;
    QWidget *scrollContent;

    //show the packets
private slots:
    void onPacketCaptured(const QString &time,const QString &from ,const QString &to,
                          const QString &length,const QString &protocol ,const QString &info);



};

#endif // CAPTUREPAGE_H
